const { dealModule } = require("./config.util");

let presets = ['@babel/preset-env'];
let plugins = ['@babel/plugin-proposal-class-properties', ['@babel/plugin-transform-modules-amd', {baseUrl: "dist"}]];

// 生成编译 babel 的命令。
let generateOrders = () => {
    return `babel --config-file ${__filename} --out-dir dist js -w`
}

let setArrDeal = moduleArr => {
    return moduleArr.map( 
        (moduleName) => {
            if (typeof moduleName === 'string') {
                return dealModule(moduleName);
            } else if (Array.isArray(moduleName)) {
                return [dealModule(moduleName[0]), moduleName[1]]
            } else {
                return moduleName;
            }
        }
    )
}
    

presets = setArrDeal(presets);
plugins = setArrDeal(plugins);

// console.log(generateOrders());
module.exports = {
    presets, plugins
}